package com.aigou.admin.aigouspringboot.service.impl;



import com.aigou.admin.aigouspringboot.common.Constants;
import com.aigou.admin.aigouspringboot.entity.Sales;
import com.aigou.admin.aigouspringboot.mapper.SalesMapper;
import com.aigou.admin.aigouspringboot.service.SalesService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SalesServiceImpl implements SalesService {

    @Resource
    private SalesMapper salesMapper;

    @Override
    public List<Sales> selectAll() {
        return salesMapper.selectAll();
    }

    @Override
    public PageInfo<Sales> selectSalesByPage(Integer current) {
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        List<Sales> salesList=salesMapper.selectAll();
        return new PageInfo<>(salesList);
    }

    @Override
    public Sales selectById(String id) {
        return salesMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteById(String id) {
        return salesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Sales sales) {
        return salesMapper.insert(sales);
    }

    @Override
    public int edit(Sales sales) {
        return salesMapper.updateByPrimaryKeySelective(sales);
    }
}
